<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
  <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
  <script src="mustache.min.js"></script>
 </HEAD>
 <BODY>


 <script>

  $(function(){
	 $.ajax({
		 type: "get",
		 async: false,
		 url: "http://localhost:8080/category/listsub.do",
		 dataType: "jsonp",
		 jsonp: "callback",//params key eg. callback=
		 jsonpCallback:"callback",//params value eg. callback=callback
		 success: function(data){
			data.forEach(function(e){
				//$("#category").append('<option value="'+e.id+'">'+e.name+'</option>');
				var template = $('#testTpl').html();
				Mustache.parse(template);
				var rendered = Mustache.render(template,e);
				$("#category").append(rendered);
			});
		 },
		 error: function(){
			 alert('fail');
		 }
	 });

	 $.ajax({
		 type: "get",
		 async: false,
		 url: "http://localhost:8080/category/list.do",
		 dataType: "jsonp",
		 jsonp: "callback",//params key eg. callback=
		 jsonpCallback:"callback2",//params value eg. callback=callback
		 success: function(data){
			data.forEach(function(e){
				var template = $('#categoryTpl').html();
				Mustache.parse(template);
				var rendered = Mustache.render(template,e);
				$("#categorylist").append(rendered);
			});
		 },
		 error: function(){
			 alert('fail');
		 }
	 });
});
</script>



<br/>
名称:<input type="text" name="name" value=""/></br>
上级类目:
<select name="parentId" id="category">
	<option value="">请选择类目</option>
</select>
</br>


<table id="categorylist">
	<tr>
		<td>id</td>
		<td>parent</td>
		<td>name</td>
		<td>path</td>
		<td>description</td>
		<td>operation</td>
	</tr>
</table>


<script type="text/html" id="testTpl">
	<option value="{{id}}">{{name}}</option>
</script>

<script type="text/html" id="categoryTpl">
	<tr>
		<td>{{id}}</td>
		<td>{{parentId}}</td>
		<td>{{name}}</td>
		<td>{{path}}</td>
		<td>{{description}}</td>
		<td>view/del/edit</td>
	</tr>
</script>
 </BODY>
</HTML>
